package Dungeoneering.Utils;

import org.powerbot.game.api.methods.widget.Camera;

/**
 * These are some Camera Utilities that the CameraHandler and Mouse Handler use
 * @author Nicolaas
 *
 */
public class CameraUtils {
	
	private static int SEGMENT_DEGREES = 45;
	
	public enum CameraDirection { NORTH, NORTH_WEST, WEST, SOUTH_WEST, SOUTH, SOUTH_EAST, EAST, NORTH_EAST };
	
	// angle 360/0 = north, 90 = west
	
	public static CameraDirection getCameraDirection() {
		int angle = Camera.getYaw();
		double start = (double)SEGMENT_DEGREES / 2;
		if (angle > (0 * SEGMENT_DEGREES) + start && angle <= (1 * SEGMENT_DEGREES) + start)
			return CameraDirection.NORTH_WEST;
		if (angle > (1 * SEGMENT_DEGREES) + start && angle <= (2 * SEGMENT_DEGREES) + start)
			return CameraDirection.WEST;
		if (angle > (2 * SEGMENT_DEGREES) + start && angle <= (3 * SEGMENT_DEGREES) + start)
			return CameraDirection.SOUTH_WEST;
		if (angle > (3 * SEGMENT_DEGREES) + start && angle <= (4 * SEGMENT_DEGREES) + start)
			return CameraDirection.SOUTH;
		if (angle > (4 * SEGMENT_DEGREES) + start && angle <= (5 * SEGMENT_DEGREES) + start)
			return CameraDirection.SOUTH_EAST;
		if (angle > (5 * SEGMENT_DEGREES) + start && angle <= (6 * SEGMENT_DEGREES) + start)
			return CameraDirection.EAST;
		if (angle > (6 * SEGMENT_DEGREES) + start && angle <= (7 * SEGMENT_DEGREES) + start)
			return CameraDirection.NORTH_EAST;
		return CameraDirection.NORTH;
	}

}
